package pers.jason.wppm.security.core.social.oicq.connect;

import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;
import pers.jason.wppm.security.core.social.oicq.dto.OicqUser;
import pers.jason.wppm.security.core.social.oicq.api.OicqApiBinding;

/**
 * 将服务提供商返回的用户信息封装成 ConnectionValues 对象
 */
public class OicqUserAdapter implements ApiAdapter<OicqApiBinding> {

    @Override
    public boolean test(OicqApiBinding api) {
        return true;
    }

    @Override
    public void setConnectionValues(OicqApiBinding api, ConnectionValues values) {
        OicqUser user = api.getOicqUser();
        values.setDisplayName(user.getNickname());
        values.setImageUrl(user.getFigureurl_qq_1());
        values.setProfileUrl(null);
        values.setProviderUserId(user.getOpenId());

    }

    @Override
    public UserProfile fetchUserProfile(OicqApiBinding api) {
        return null;
    }

    @Override
    public void updateStatus(OicqApiBinding api, String message) {

    }
}
